package com.etrans.web.gps.business.report.service;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;

import org.apache.commons.lang3.StringUtils;
import org.bson.Document;
import org.springframework.stereotype.Service;

import com.etrans.web.gps.base.service.BaseService;
import com.etrans.web.gps.business.report.domain.EnterpriseQcVO;
import com.etrans.web.gps.business.report.domain.EnterpriseSwap;
import com.etrans.web.gps.common.MGTemplete;
import com.etrans.web.gps.util.DateUtil;
import com.mongodb.QueryOperators;

/**
 * @author zhangw
 * @date 2017年9月4日
 * @ClassName:  EnterpiseAnalyzesService  
 * @param:   
 */
@Service
public class EnterpiseAnalyzesService extends BaseService{
	
	public static List<Integer> areaIdList;

	/**
	 * 查询登录用户权限下的所有业户的ID
	 * @return  业户信息列表
	 */
	public List<Integer> queryAreaIdListByRole(int areaId){
		HashMap<String, Object> param = new HashMap<String, Object>();
		param.put("FullID", String.format("%08d",areaId));
		 List<Integer> list = this.selectList("tourismViolation.queryAreaIdListByRole",param);
		 setAreaIdList(list);
		return  list;
	}
	
	/**
	 * select2动态根据业户名查询业户
	 * @return  业户信息
	 */
	public List<HashMap<String, Object>> queryEnterAndPlatByRole(int areaId,String enterprise_name) {
		HashMap<String,Object> param = new HashMap<String,Object>();
		param.put("FullID", String.format("%08d",areaId));
		param.put("enterprise_name", enterprise_name);
		return selectList("tourismViolation.queryEnterpriseByName",param);
	}
	
	/**
	 * 查询业户综合分析信息(表1)
	 * @param areaIdList    访问用户权限下所有的区域id
	 * @param enterprise_id 查询业户id
	 * @param queryType     查询时间类型
	 * @param inputTime     时间值
	 * @return
	 */
	public List<HashMap<String,Object>> queryEnterpriseSwap1(List<Integer> areaIdList,String enterprise_id,Integer queryType,String inputTime){
		List<HashMap<String,Object>> list = new ArrayList<HashMap<String,Object>>();
		try {
			//whereMap过滤条件
			HashMap<String,Object> whereMap = new HashMap<String,Object>();
			HashMap<String,Object> map = new HashMap<String,Object>();
			map.put(QueryOperators.IN,areaIdList);
			whereMap.put("area_id", map);
			if(enterprise_id!=null&&!"".equals(String.valueOf(enterprise_id))){
				whereMap.put("enterprise_id",Integer.valueOf(enterprise_id));
			}
			//查询表名
			String tableName = "";
			if (queryType == 1) {
				tableName = "enterprise_swap";
			}else if (queryType == 2) {
				tableName = "enterprise_swap_week";
				Integer year = Integer.valueOf(inputTime.substring(0,4));
				Integer week = Integer.valueOf(inputTime.substring(5,7));
				Map<String,Object> timeMap = DateUtil.getYearAndWeekByDate(year, week);
				String startStr = String.valueOf(timeMap.get("Monday"));
				inputTime = startStr.substring(2,4)+startStr.substring(5,7)+startStr.substring(8,10);
			}else if (queryType == 3) {
				tableName = "enterprise_swap_month";
			}else if (queryType == 4) {
				tableName = "enterprise_swap_season";
			}else if (queryType == 5) {
				tableName = "enterprise_swap_year";
			}
			//查询文档id
			String queryId = inputTime;
			Pattern pat = Pattern.compile("^"+queryId);
			whereMap.put("_id", pat);
			HashMap<String, Object> resultMap = getEntFieldsMap1();
			List<Document> resultList = MGTemplete.find("egov", tableName,whereMap,resultMap,true);
			for (Document doc : resultList) {
				HashMap<String,Object> reMap = new HashMap<String,Object>();
				reMap.put("enterprise_name", doc.getString("enterprise_name"));
				reMap.put("enterprise_id", doc.getInteger("enterprise_id"));
				reMap.put("vehicle_count", doc.getInteger("vehicle_count"));
				reMap.put("vehicle_access_count", doc.getInteger("vehicle_access_count"));
				reMap.put("vehicle_access_rate", doc.getDouble("vehicle_access_rate"));
				reMap.put("vehicle_online_count", doc.getInteger("vehicle_online_count"));
				reMap.put("vehicle_online_rate", doc.getDouble("vehicle_online_rate"));
				list.add(reMap);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return list;
	}
	/**
	 * 查询业户综合分析信息(表2)
	 * @param areaIdList    访问用户权限下所有的区域id
	 * @param enterprise_id 查询业户id
	 * @param queryType     查询时间类型
	 * @param inputTime     时间值
	 * @return
	 */
	public List<HashMap<String,Object>> queryEnterpriseSwap2(List<Integer> areaIdList,String enterprise_id,Integer queryType,String inputTime){
		List<HashMap<String,Object>> list = new ArrayList<HashMap<String,Object>>();
		try {
			//whereMap过滤条件
			HashMap<String,Object> whereMap = new HashMap<String,Object>();
			HashMap<String,Object> map = new HashMap<String,Object>();
			map.put(QueryOperators.IN,areaIdList);
			whereMap.put("area_id", map);
			if(enterprise_id!=null&&!"".equals(String.valueOf(enterprise_id))){
				whereMap.put("enterprise_id",Integer.valueOf(enterprise_id));
			}
			//查询表名
			String tableName = "";
			if (queryType == 1) {
				tableName = "enterprise_swap";
			}else if (queryType == 2) {
				tableName = "enterprise_swap_week";
				Integer year = Integer.valueOf(inputTime.substring(0,4));
				Integer week = Integer.valueOf(inputTime.substring(5,7));
				Map<String,Object> timeMap = DateUtil.getYearAndWeekByDate(year, week);
				String startStr = String.valueOf(timeMap.get("Monday"));
				inputTime = startStr.substring(2,4)+startStr.substring(5,7)+startStr.substring(8,10);
			}else if (queryType == 3) {
				tableName = "enterprise_swap_month";
			}else if (queryType == 4) {
				tableName = "enterprise_swap_season";
			}else if (queryType == 5) {
				tableName = "enterprise_swap_year";
			}
			//查询文档id
			String queryId = inputTime;
			Pattern pat = Pattern.compile("^"+queryId);
			whereMap.put("_id", pat);
			HashMap<String, Object> resultMap = getEntFieldsMap2();
			List<Document> resultList = MGTemplete.find("egov", tableName,whereMap,resultMap,true);
			for (Document doc : resultList) {
				HashMap<String,Object> reMap = new HashMap<String,Object>();
				reMap.put("enterprise_name", doc.getString("enterprise_name"));
				Document d = (Document) doc.get("trade_obj");
				Document regularBus = (Document) d.get("1");
				Document touringCar = (Document) d.get("2");
				Document dangerCar = (Document) d.get("3");
				reMap.put("regularBus", regularBus.get("vehicle_count")+","+regularBus.get("vehicle_access_count")+"("
						+regularBus.getDouble("vehicle_access_rate")+"%)"+","+regularBus.get("vehicle_online_count")+"("
						+regularBus.getDouble("vehicle_online_rate")+"%)");
				reMap.put("touringCar",touringCar.get("vehicle_count")+","+touringCar.get("vehicle_access_count")+"("
						+touringCar.getDouble("vehicle_access_rate")+"%)"+","+touringCar.get("vehicle_online_count")+"("
						+touringCar.getDouble("vehicle_online_rate")+"%)");
				reMap.put("dangerCar",dangerCar.get("vehicle_count")+","+dangerCar.get("vehicle_access_count")+"("
						+dangerCar.getDouble("vehicle_access_rate")+"%)"+","+dangerCar.get("vehicle_online_count")+"("
						+dangerCar.getDouble("vehicle_online_rate")+"%)");
				list.add(reMap);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return list;
	}
	/**
	 * 查询业户综合分析信息(表3)
	 * @param areaIdList    访问用户权限下所有的区域id
	 * @param enterprise_id 查询业户id
	 * @param queryType     查询时间类型
	 * @param inputTime     时间值
	 * @return
	 */
	public List<HashMap<String,Object>> queryEnterpriseSwap3(List<Integer> areaIdList,String enterprise_id,Integer queryType,String inputTime){
		List<HashMap<String,Object>> list = new ArrayList<HashMap<String,Object>>();
		try {
			//whereMap过滤条件
			HashMap<String,Object> whereMap = new HashMap<String,Object>();
			HashMap<String,Object> map = new HashMap<String,Object>();
			map.put(QueryOperators.IN,areaIdList);
			whereMap.put("area_id", map);
			if(enterprise_id!=null&&!"".equals(String.valueOf(enterprise_id))){
				whereMap.put("enterprise_id",Integer.valueOf(enterprise_id));
			}
			//查询表名
			String tableName = "";
			if (queryType == 1) {
				tableName = "enterprise_swap";
			}else if (queryType == 2) {
				tableName = "enterprise_swap_week";
				Integer year = Integer.valueOf(inputTime.substring(0,4));
				Integer week = Integer.valueOf(inputTime.substring(5,7));
				Map<String,Object> timeMap = DateUtil.getYearAndWeekByDate(year, week);
				String startStr = String.valueOf(timeMap.get("Monday"));
				inputTime = startStr.substring(2,4)+startStr.substring(5,7)+startStr.substring(8,10);
			}else if (queryType == 3) {
				tableName = "enterprise_swap_month";
			}else if (queryType == 4) {
				tableName = "enterprise_swap_season";
			}else if (queryType == 5) {
				tableName = "enterprise_swap_year";
			}
			//查询文档id
			String queryId = inputTime;
			Pattern pat = Pattern.compile("^"+queryId);
			whereMap.put("_id", pat);
			HashMap<String, Object> resultMap = getEntFieldsMap3();
			List<Document> resultList = MGTemplete.find("egov", tableName,whereMap,resultMap,true);
			for (Document doc : resultList) {
				HashMap<String,Object> reMap = new HashMap<String,Object>();
				reMap.put("enterprise_name", doc.getString("enterprise_name"));
				reMap.put("alarm_vehicle_count", doc.getInteger("alarm_vehicle_count"));
				reMap.put("alarm_count", doc.getInteger("alarm_count"));
				reMap.put("alarm_processed", doc.getInteger("alarm_processed"));
				reMap.put("alarm_processed_rate","");
				reMap.put("overspeed_count", doc.getInteger("overspeed_count"));
				reMap.put("tired_duration", doc.getInteger("tired_duration"));
				reMap.put("vehicle_alarm_rate", "");
				reMap.put("vehicle_online_count", doc.getInteger("vehicle_online_count"));
				reMap.put("avg_vehicle_speed_counts", doc.getDouble("avg_vehicle_speed_counts"));
				reMap.put("avg_vehicle_tired_duration", doc.getDouble("avg_vehicle_tired_duration"));
				list.add(reMap);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return list;
	}
	/**
	 * 查询业户综合分析信息(表4)
	 * @param areaIdList    访问用户权限下所有的区域id
	 * @param enterprise_id 查询业户id
	 * @param queryType     查询时间类型
	 * @param inputTime     时间值
	 * @return
	 */
	public List<HashMap<String,Object>> queryEnterpriseSwap4(List<Integer> areaIdList,String enterprise_id,Integer queryType,String inputTime){
		List<HashMap<String,Object>> list = new ArrayList<HashMap<String,Object>>();
		try {
			//whereMap过滤条件
			HashMap<String,Object> whereMap = new HashMap<String,Object>();
			HashMap<String,Object> map = new HashMap<String,Object>();
			map.put(QueryOperators.IN,areaIdList);
			whereMap.put("area_id", map);
			if(enterprise_id!=null&&!"".equals(String.valueOf(enterprise_id))){
				whereMap.put("enterprise_id",Integer.valueOf(enterprise_id));
			}
			//查询表名
			String tableName = "";
			if (queryType == 1) {
				tableName = "enterprise_swap";
			}else if (queryType == 2) {
				tableName = "enterprise_swap_week";
				Integer year = Integer.valueOf(inputTime.substring(0,4));
				Integer week = Integer.valueOf(inputTime.substring(5,7));
				Map<String,Object> timeMap = DateUtil.getYearAndWeekByDate(year, week);
				String startStr = String.valueOf(timeMap.get("Monday"));
				inputTime = startStr.substring(2,4)+startStr.substring(5,7)+startStr.substring(8,10);
			}else if (queryType == 3) {
				tableName = "enterprise_swap_month";
			}else if (queryType == 4) {
				tableName = "enterprise_swap_season";
			}else if (queryType == 5) {
				tableName = "enterprise_swap_year";
			}
			//查询文档id
			String queryId = inputTime;
			Pattern pat = Pattern.compile("^"+queryId);
			whereMap.put("_id", pat);
			HashMap<String, Object> resultMap = getEntFieldsMap4();
			List<Document> resulist = MGTemplete.find("egov", tableName,whereMap,resultMap,true);
			for (Document doc : resulist) {
				HashMap<String,Object> reMap = new HashMap<String,Object>();
				reMap.put("enterprise_name", doc.getString("enterprise_name"));
				reMap.put("exception_vehicle_count", doc.getInteger("exception_vehicle_count"));
				reMap.put("vehicle_online_count", doc.getInteger("vehicle_online_count"));
				reMap.put("location_exception_count", doc.getInteger("location_exception_count"));
				reMap.put("speed_160_count", doc.getInteger("speed_160_count"));
				reMap.put("gpstime_exception_count", doc.getInteger("gpstime_exception_count"));
				reMap.put("head_exception_count", doc.getInteger("head_exception_count"));
				reMap.put("exception_track_count", doc.getInteger("exception_track_count"));
				reMap.put("track_normal", doc.getInteger("track_normal"));
				reMap.put("exception_rate", "");
				reMap.put("exception_contrast_rate","");
				list.add(reMap);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return list;
	}
	/**
	 * 业户考核查询
	 * @param areaIdList
	 * @param enterprise
	 * @param queryType
	 * @param inputTime
	 * @return
	 */
	public List<EnterpriseQcVO> queryEnterpriseQc(List<Integer> areaIdList,String enterprise_id,Integer queryType,String inputTime){
		List<EnterpriseQcVO> list = new ArrayList<EnterpriseQcVO>();
		
		try {
			//whereMap过滤条件
			HashMap<String,Object> whereMap = new HashMap<String,Object>();
			HashMap<String,Object> map = new HashMap<String,Object>();
			map.put("$in",areaIdList);
			whereMap.put("area_id", map);
			//查询表名
			String tableName = "";
			if (queryType == 1) {
				tableName = "enterprise_swap";
			}else if (queryType == 2) {
				tableName = "enterprise_swap_week";
				Integer year = Integer.valueOf(inputTime.substring(0,4));
				Integer week = Integer.valueOf(inputTime.substring(5,7));
				Map<String,Object> timeMap = DateUtil.getYearAndWeekByDate(year, week);
				String startStr = String.valueOf(timeMap.get("Monday"));
				inputTime = startStr.substring(2,4)+startStr.substring(5,7)+startStr.substring(8,10);
			}else if (queryType == 3) {
				tableName = "enterprise_swap_month";
			}else if (queryType == 4) {
				tableName = "enterprise_swap_season";
			}else if (queryType == 5) {
				tableName = "enterprise_swap_year";
			}
			//查询文档id
			String queryId = inputTime;
			Pattern pat = Pattern.compile("^"+queryId);
			whereMap.put("_id", pat);
			HashMap<String, Object> resultMap = getQcFieldsMap();
			//resultList = MGTemplete.find("egov", tableName,whereMap,EnterpriseQcVO.class,true,resultMap);
			List<Document> resultList = MGTemplete.find("egov", tableName,whereMap,resultMap,true);
			
			for (Document doc : resultList) {
				EnterpriseQcVO vo = new EnterpriseQcVO();
				vo.setEnterprise_id(doc.getInteger("enterprise_id"));
				vo.setEnterprise_name(doc.getString("enterprise_name"));
				vo.setScore(doc.getInteger("score"));
				vo.setVehicle_access_rate(doc.getDouble("vehicle_access_rate"));
				vo.setVehicle_online_rate(doc.getDouble("vehicle_online_rate"));
				vo.setTrack_complete_rate(doc.getDouble("track_complete_rate"));
				vo.setData_correct_rate(doc.getDouble("data_correct_rate"));
				vo.setLocation_exception_count(doc.getInteger("location_exception_count"));
				vo.setSpeed_160_count(doc.getInteger("speed_160_count"));
				vo.setGpstime_exception_count(doc.getInteger("gpstime_exception_count"));
				vo.setHead_exception_count(doc.getInteger("head_exception_count"));
				vo.setVehicle_online_count(doc.getInteger("vehicle_online_count"));
				vo.setException_vehicle_count(doc.getInteger("exception_vehicle_count"));
				vo.setAvg_vehicle_tired_duration(doc.getDouble("avg_vehicle_tired_duration"));
				vo.setAvg_vehicle_speed_counts(doc.getDouble("avg_vehicle_speed_counts"));
				vo.setReply_correct_count(doc.getInteger("location_exception_count"));
				vo.setCheck_count(doc.getInteger("check_count"));
				Object adas_alarm_count = doc.get("adas_alarm_count");
				vo.setAdas_alarm_count(StringUtils.isNumeric(adas_alarm_count+"")?Long.valueOf(adas_alarm_count+""):0);
				list.add(vo);
			}
			if (list != null) {
				Collections.sort(list,Collections.reverseOrder(new Comparetores()));
				int order = 1;
				for (int i = 0; i < list.size(); i ++) {
					double platScore1 = list.get(i).getScore();
					if (i < list.size() - 1) {
						double platScore2 = list.get(i + 1).getScore();
						if (platScore1 != platScore2) {
							list.get(i).setRanking(order);
							order ++;
						}else {
							list.get(i).setRanking(order);
						}
					}else {
						list.get(i).setRanking(order);
					}
					if(enterprise_id!=null&&!"".equals(String.valueOf(enterprise_id))){
						if (list.get(i).getEnterprise_id() == Integer.valueOf(enterprise_id)) {
							List<EnterpriseQcVO> reList = new ArrayList<EnterpriseQcVO>();
							 reList.add(list.get(i));
							 return reList;
						} 
					}
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
			
		}
		return list;
	}
	
	
	
	/**
	 * 查询柱状图数据
	 * @param enterprise
	 * @param startTime
	 * @param endTime
	 * @return
	 */
	public List<EnterpriseSwap> queryBarChart(Integer enterprise_id,Integer queryType,String inputTime){
		List<EnterpriseSwap> reslist = null;
		try {
			//whereMap过滤条件
			HashMap<String,Object> whereMap = new HashMap<String,Object>();
			whereMap.put("enterprise_id",enterprise_id);
			//查询表名
			String tableName = "";
			if (queryType == 1) {
				tableName = "enterprise_swap";
				Pattern pat = Pattern.compile("^"+inputTime);
				whereMap.put("_id", pat);
			}else if (queryType == 2) {
				tableName = "enterprise_swap";
				SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
				Integer year = Integer.valueOf(inputTime.substring(0,4));
				Integer week = Integer.valueOf(inputTime.substring(5,7));
				Map<String,Object> timeMap = DateUtil.getYearAndWeekByDate(year, week);
				String startStr = String.valueOf(timeMap.get("Monday"));
				String endStr = String.valueOf(timeMap.get("Sunday"));
				Date startTime = sdf.parse(startStr+" 00:00:00");
				Date endTime = sdf.parse(endStr+" 23:59:59");
				HashMap<String,Object> whereMap_Time = new HashMap<String, Object>();
				whereMap_Time.put("$gte", startTime);	//大于
				whereMap_Time.put("$lte", endTime);		//小于
				whereMap.put("analyse_date", whereMap_Time);
			}else if (queryType == 3) {
				tableName = "enterprise_swap_week";
				Integer year = Integer.valueOf(inputTime.substring(0,4));
				Integer month = Integer.valueOf(inputTime.substring(5,7));
				SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
				Date startTime = sdf.parse(DateUtil.getFirstDayOfMonth(year,month)+" 00:00:00");
				Date endTime = sdf.parse(DateUtil.getLastDayOfMonth(year,month)+" 23:59:59");
				HashMap<String,Object> whereMap_Time = new HashMap<String, Object>();
				whereMap_Time.put("$gte", startTime);	//大于
				whereMap_Time.put("$lte", endTime);		//小于
				whereMap.put("analyse_date", whereMap_Time);
			}else if (queryType == 4) {
				tableName = "enterprise_swap_season";
			}else if (queryType == 5) {
				tableName = "enterprise_swap_year";
			}
			HashMap<String,Object> sortMap = new HashMap<String,Object>();
			sortMap.put("analyse_date", 1);
			reslist = MGTemplete.find("egov", tableName,whereMap,sortMap,EnterpriseSwap.class);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return reslist;
	}
	
	/**
	 * 排序
	 * @ClassName:  Comparetores  
	 * @param: Comparator<T>
	 */
	public static class Comparetores implements Comparator<EnterpriseQcVO>{
		public int compare(EnterpriseQcVO analyzes1, EnterpriseQcVO analyzes2) {
	        double maxs= analyzes1.getScore()-analyzes2.getScore();
	        int or = 0;
	         if(maxs > 0){
	        	 or = 1;
	         }else if(maxs < 0){
	        	 or = -1;
	         }
	         return or;
		}		
	}

	/**
	 * 获取业户考核查询指定字段
	 * @return
	 */
	public static HashMap<String,Object> getQcFieldsMap(){
		HashMap<String,Object> resultMap = new HashMap<String,Object>();
		resultMap.put("enterprise_id", 1);
		resultMap.put("enterprise_name", 1);
		resultMap.put("score", 1);
		resultMap.put("vehicle_access_rate", 1);
		resultMap.put("vehicle_online_rate", 1);
		resultMap.put("track_complete_rate", 1);
		resultMap.put("data_correct_rate", 1);
		resultMap.put("location_exception_count", 1);
		resultMap.put("speed_160_count", 1);
		resultMap.put("gpstime_exception_count", 1);
		resultMap.put("head_exception_count", 1);
		resultMap.put("vehicle_online_count", 1);
		resultMap.put("exception_vehicle_count", 1);
		resultMap.put("avg_vehicle_tired_duration", 1);
		resultMap.put("avg_vehicle_speed_counts", 1);
		resultMap.put("reply_correct_count", 1);
		resultMap.put("check_count", 1);
		resultMap.put("adas_alarm_count",1);
		return resultMap;
	}
	
	/**
	 * 获取业户考核查询指定字段
	 * @return
	 */
	public static HashMap<String,Object> getEntFieldsMap1(){
		HashMap<String,Object> resultMap = new HashMap<String,Object>();
		resultMap.put("enterprise_id", 1);
		resultMap.put("enterprise_name", 1);
		resultMap.put("vehicle_count", 1);
		resultMap.put("vehicle_access_count", 1);
		resultMap.put("vehicle_access_rate", 1);
		resultMap.put("vehicle_online_count", 1);
		resultMap.put("vehicle_online_rate", 1);
		return resultMap;
	}
	
	/**
	 * 获取业户考核查询指定字段
	 * @return
	 */
	public static HashMap<String,Object> getEntFieldsMap2(){
		HashMap<String,Object> resultMap = new HashMap<String,Object>();
		resultMap.put("enterprise_name", 1);
		resultMap.put("trade_obj", 1);
		return resultMap;
	}
	
	/**
	 * 获取业户考核查询指定字段
	 * @return
	 */
	public static HashMap<String,Object> getEntFieldsMap3(){
		HashMap<String,Object> resultMap = new HashMap<String,Object>();
		resultMap.put("enterprise_name", 1);
		resultMap.put("alarm_vehicle_count", 1);
		resultMap.put("alarm_count", 1);
		resultMap.put("alarm_processed", 1);
		resultMap.put("overspeed_count", 1);
		resultMap.put("tired_duration", 1);
		resultMap.put("tired_duration", 1);
		resultMap.put("avg_vehicle_speed_counts", 1);
		resultMap.put("avg_vehicle_tired_duration", 1);
		resultMap.put("vehicle_online_count", 1);
		return resultMap;
	}
	
	/**
	 * 获取业户考核查询指定字段
	 * @return
	 */
	public static HashMap<String,Object> getEntFieldsMap4(){
		HashMap<String,Object> resultMap = new HashMap<String,Object>();
		resultMap.put("enterprise_name", 1);
		resultMap.put("exception_vehicle_count", 1);
		resultMap.put("vehicle_online_count", 1);
		resultMap.put("location_exception_count", 1);
		resultMap.put("speed_160_count", 1);
		resultMap.put("gpstime_exception_count", 1);
		resultMap.put("head_exception_count", 1);
		resultMap.put("exception_track_count", 1);
		resultMap.put("track_normal", 1);
		return resultMap;
	}
	
	/**
	 * 获取指定字段
	 * @return
	 */
	public static HashMap<String,Object> getResultMap(){
		HashMap<String,Object> resultMap = new HashMap<String,Object>();
		resultMap.put("enterprise_id", 1);
		resultMap.put("enterprise_name", 1);
		resultMap.put("score", 1);
		resultMap.put("check_count", 1);
		resultMap.put("analyse_date", 1);
		//resultMap.put("reply_count", 1);
		//resultMap.put("reply_rate", 1);
		resultMap.put("reply_correct_count", 1);
		resultMap.put("vehicle_count", 1);
		resultMap.put("vehicle_access_count", 1);
		resultMap.put("vehicle_online_count", 1);
		resultMap.put("vehicle_access_rate", 1);
		resultMap.put("vehicle_online_rate", 1);
		resultMap.put("data_correct_rate", 1);
		resultMap.put("location_exception_rate", 1);
		resultMap.put("track_normal", 1);
		resultMap.put("alarm_vehicle_count", 1);
		resultMap.put("alarm_count", 1);
		resultMap.put("alarm_processed", 1);
		resultMap.put("overspeed_count", 1);
		resultMap.put("tired_duration", 1);
		resultMap.put("speed_160_count", 1);
		resultMap.put("track_complete_rate", 1);
		resultMap.put("exception_track_count", 1);
		resultMap.put("gpstime_exception_count", 1);
		resultMap.put("location_exception_count", 1);
		resultMap.put("speed_exception_count", 1);
		resultMap.put("head_exception_count", 1);
		resultMap.put("notrack_vehicle_count", 1);
		resultMap.put("avg_vehicle_tired_duration", 1);
		resultMap.put("avg_vehicle_speed_counts", 1);
		resultMap.put("exception_vehicle_count", 1);
		resultMap.put("vehicle_alarm_rate", 1);
		resultMap.put("trade_obj", 1);
		/*		resultMap.put("overspeed_processed", 1);
		resultMap.put("roadoffset_count", 1);
		resultMap.put("roadoffset_processed", 1);
		resultMap.put("tired_count", 1);
		resultMap.put("tired_processed", 1);
		resultMap.put("data_fault_rate", 1);
		//resultMap.put("area_id", 1);
		resultMap.put("prohibit_driving_count", 1);
		resultMap.put("prohibit_driving_processed", 1);
		resultMap.put("nightly_3rd_count", 1);
		resultMap.put("nightly_3rd_processed", 1);
		resultMap.put("over_load_count", 1);
		resultMap.put("over_load_processed", 1);
		resultMap.put("overspeed_100_count", 1);*/
		return resultMap;
	}
	
	public List<Integer> getAreaIdList() {
		return areaIdList;
	}

	public void setAreaIdList(List<Integer> areaIdList) {
		EnterpiseAnalyzesService.areaIdList = areaIdList;
	}

}

